package com.apress.springrecipes.weather;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Client {
	
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("client.xml");
		WeatherService service = (WeatherService) context.getBean("weatherService");
		List<Date> dates = new ArrayList<Date>();
		dates.add(new Date());
		List<TemperatureInfo> temperatures = service.getTemperatures("Houston",dates);
		TemperatureInfo temperature = temperatures.get(0);
		System.out.println("City : " + temperature.getCity());
		System.out.println("Date : " + temperature.getDate());
		System.out.println("Min temperature : " + temperature.getMin());
		System.out.println("Max temperature : " + temperature.getMax());
		System.out.println("Average temperature : " + temperature.getAverage());
	}
}
